<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="security" uri="http://www.springframework.org/security/tags" %>
<html>

<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <title>工程施工实时监控系统</title>
    <meta name="description" content="AdminLTE2定制版">
    <meta name="keywords" content="AdminLTE2定制版">


    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">

    <!--<link rel="stylesheet" href="${pageContext.request.contextPath}/${pageContext.request.contextPath}/${pageContext.request.contextPath}/plugins/timepicker/bootstrap-timepicker.min.css">-->

    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>


    <!--<script src="${pageContext.request.contextPath}/${pageContext.request.contextPath}/${pageContext.request.contextPath}/plugins/timepicker/bootstrap-timepicker.min.js"></script>-->

    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/ionicons/css/ionicons.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/iCheck/square/blue.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/morris/morris.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/jvectormap/jquery-jvectormap-1.2.2.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/datepicker/datepicker3.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/daterangepicker/daterangepicker.css">
    <link rel="stylesheet"
          href="${pageContext.request.contextPath}/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/datatables/dataTables.bootstrap.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/treeTable/jquery.treetable.css">
    <link rel="stylesheet"
          href="${pageContext.request.contextPath}/plugins/treeTable/jquery.treetable.theme.default.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/select2/select2.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/colorpicker/bootstrap-colorpicker.min.css">
    <link rel="stylesheet"
          href="${pageContext.request.contextPath}/plugins/bootstrap-markdown/css/bootstrap-markdown.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/adminLTE/css/AdminLTE.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/adminLTE/css/skins/_all-skins.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/style.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/ionslider/ion.rangeSlider.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/ionslider/ion.rangeSlider.skinNice.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/bootstrap-slider/slider.css">
    <link rel="stylesheet"
          href="${pageContext.request.contextPath}/plugins/bootstrap-datetimepicker/bootstrap-datetimepicker.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/layui/css/layui.css" media="all">
    <style>
        .content {
            padding-bottom: 25px;
        }

        /*使layui数据表格的checkbox居中*/
        .layui-table-cell .layui-form-checkbox[lay-skin="primary"] {
            top: 50%;
            transform: translateY(-50%);
        }

        .layui-form-item {
            height: 40px;
        }

        .layui-form-label {
            width: 100px;
        }

        b {
            font-size: 20px;
            margin: 17px;
            float: left;
        }

        .mytd {
            text-align: center;
            border: 1px #F2F2F2 solid;
            width: 500px;
            height: 30px;
        }

        #tesu_select {
            border: 1px solid #277de2;
            /*border-radius:4px;*/
        }

    </style>
</head>

<body class="hold-transition skin-purple sidebar-mini">

<div class="wrapper">
    <security:authentication property="principal.id" var="id"
    ></security:authentication>
    <!-- 页面头部 -->
    <jsp:include page="header.jsp"></jsp:include>
    <!-- 页面头部 /-->

    <!-- 导航侧栏 -->
    <jsp:include page="aside.jsp"></jsp:include>
    <!-- 导航侧栏 /-->

    <!-- 内容区域 -->
    <!-- @@master = admin-layout.html-->
    <!-- @@block = content -->

    <div class="content-wrapper" style="height: 850px">

        <!-- 内容头部 -->
        <section class="content-header">
            <h1>
                设备管理
                <%--<small>数据列表</small>--%>
            </h1>
            <ol class="breadcrumb">
                <li><a href="${pageContext.request.contextPath}/pages/main.jsp"><i class="fa fa-dashboard"></i> 首页</a>
                </li>
                <li class="active">设备管理</li>
            </ol>
        </section>
        <!-- 内容头部 /-->

        <!-- 正文区域 -->
        <section class="content">

            <!-- .box-body -->
            <div class="box box-primary">
                <%--新增用户表单--%>
                <div class="site-text" style="margin: 5%; display: none" id="addDeviceWindow" target="test123">
                    <%--<form class="layui-form" id="book" method="post" lay-filter="example">--%>
                    <%--<div class="layui-form-item">--%>
                    <%--<label class="layui-form-label">设备编号</label>--%>
                    <%--<div class="layui-input-block">--%>
                    <%--<input type="text" id="devNum" name="devNum" lay-verify="required"--%>
                    <%--lay-filter="devNum" autocomplete="off" placeholder="请输入设备编号"--%>
                    <%--class="layui-input">--%>
                    <%--</div>--%>
                    <%--</div>--%>
                    <%--<div class="layui-form-item">--%>
                    <%--<label class="layui-form-label">机器编号</label>--%>
                    <%--<div class="layui-input-block">--%>
                    <%--<input type="text" id="machineNum" name="machineNum" lay-verify="required"--%>
                    <%--lay-filter="machineNum" autocomplete="off" placeholder="请输入机器编号"--%>
                    <%--class="layui-input">--%>
                    <%--</div>--%>
                    <%--</div>--%>


                    <%--<div class="layui-form-item">--%>
                    <%--<label class="layui-form-label">所属项目</label>--%>
                    <%--<div class="layui-input-block">--%>
                    <%--<select name="projectVal" id="projectVal" lay-filter="projectVal">--%>
                    <%--<option value="">请选择项目</option>--%>
                    <%--</select>--%>
                    <%--</div>--%>
                    <%--</div>--%>
                    <%--<div class="layui-form-item">--%>
                    <%--<label class="layui-form-label">所属标段</label>--%>
                    <%--<div class="layui-input-block" id="sectionVal">--%>
                    <%--<select name="section_id" id="section_id" lay-filter="section_id">--%>
                    <%--<option value="">请选择标段</option>--%>
                    <%--</select>--%>
                    <%--</div>--%>
                    <%--</div>--%>

                    <%--<div class="layui-form-item">--%>
                    <%--<label class="layui-form-label">设备类型</label>--%>
                    <%--<div class="layui-input-block">--%>
                    <%--<select name="state" id="devCode" lay-filter="devCode">--%>
                    <%--<option value="0">双头搅拌机</option>--%>
                    <%--</select>--%>
                    <%--</div>--%>
                    <%--</div>--%>
                    <%--<div class="layui-form-item">--%>
                    <%--<label class="layui-form-label">设备厂家</label>--%>
                    <%--<div class="layui-input-block">--%>
                    <%--<input type="text" id="manufacturers" name="manufacturers" lay-verify="required"--%>
                    <%--lay-filter="manufacturers" autocomplete="off" placeholder="请输入设备厂家"--%>
                    <%--class="layui-input">--%>
                    <%--</div>--%>
                    <%--</div>--%>
                    <%--<div class="layui-form-item">--%>
                    <%--<label class="layui-form-label">排序ID</label>--%>
                    <%--<div class="layui-input-block">--%>
                    <%--<input type="text" id="orderBy" name="orderBy" lay-verify="required"--%>
                    <%--autocomplete="off"--%>
                    <%--placeholder="请输入排序ID" class="layui-input">--%>
                    <%--</div>--%>
                    <%--</div>--%>

                    <%--<div class="layui-form-item">--%>
                    <%--<label class="layui-form-label">是否启用</label>--%>
                    <%--<div class="layui-input-block">--%>
                    <%--<select name="state" id="state" lay-filter="state">--%>
                    <%--<option value="0">未激活</option>--%>
                    <%--<option value="1">已离线</option>--%>
                    <%--<option value="2">已离场</option>--%>
                    <%--<option value="3">运行中</option>--%>
                    <%--<option value="4">故障中</option>--%>
                    <%--</select>--%>
                    <%--</div>--%>
                    <%--</div>--%>
                    <%--<div class="layui-form-item">--%>
                    <%--<label class="layui-form-label">桩孔数量</label>--%>
                    <%--<div class="layui-input-block">--%>
                    <%--<input type="text" id="devTotal" name="devTotal"--%>
                    <%--autocomplete="off" lay-verify="required"--%>
                    <%--class="layui-input">--%>
                    <%--</div>--%>
                    <%--</div>--%>

                    <%--<!--  <div class="layui-form-item">--%>
                    <%--<div class="layui-input-block">--%>
                    <%--<button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>--%>
                    <%--</div>--%>
                    <%--</div> -->--%>
                    <%--</form>--%>
                </div>
                <%--end新增用户表单--%>


            </div>
            <%--<div class="demoTable">--%>
            <%--<div class="layui-form layui-card-header layuiadmin-card-header-auto" id="resetForm">--%>

            <%--<div class="layui-inline">--%>
            <%--<select name="projectId" id="projectId" lay-filter="projectId">--%>
            <%--<option value="">请选择项目</option>--%>
            <%--</select>--%>
            <%--</div>--%>
            <%--<div class="layui-inline" id="sectionSel">--%>
            <%--<select name="sectionId" id="sectionId" lay-filter="sectionId">--%>
            <%--<option value="">请选择标段</option>--%>
            <%--</select>--%>
            <%--</div>--%>
            <%--<div class="layui-inline">--%>
            <%--<input class="layui-input" autocomplete="off" name="name" id="name"--%>
            <%--placeholder="请输入设备编号">--%>
            <%--</div>--%>

            <%--<button class="layui-btn" data-type="reload">搜索</button>--%>
            <%--<button class="layui-btn" id="reset">重置</button>--%>
            <%--<button class="layui-btn" id="addDevice" style="float:right">添加设备</button>--%>


            <%--&lt;%&ndash;</div>&ndash;%&gt;--%>
            <%--</div>--%>
            <%--</div>--%>
            <div style=" background-color: #F2F2F2; height: 82%">
                <div class="layui-row layui-col-space15">
                    <div class="layui-col-md6" style="width: 56%">
                        <div class="layui-card">
                            <div class="layui-card-header" style="height: 10%"><b>搅拌桩</b></div>
                            <div class="layui-card-body" style="height: 85%">
                                <table class="layui-hide" id="workSettingTable" lay-filter="workSettingTable">

                                </table>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md6" style="width: 44%">
                        <div class="layui-card">
                            <div class="layui-card-header" style="height: 10%"><b id="b1">添加作业配置</b></div>
                            <div class="layui-card-body" style="height: 85%">
                                <form class="layui-form" id="book" method="post" lay-filter="example">
                                    <div class="layui-form-item" style="margin-bottom: 0px;width: 100%">
                                        <div class="layui-input-inline " style="width: 20%">
                                            &nbsp;&nbsp;&nbsp; <span>作业类型</span>
                                        </div>
                                        <div class="layui-input-inline " style="width: 18%">
                                            &nbsp;&nbsp;&nbsp; <span>作业名称</span>
                                        </div>
                                        <div class="layui-input-inline " style="width:18%">
                                            &nbsp;&nbsp;&nbsp; <span>作业标识</span>
                                        </div>
                                        <div class="layui-input-inline " style="width: 18%">
                                            &nbsp;&nbsp;&nbsp; <span>预警规则</span>
                                        </div>
                                        <div class="layui-input-inline " style="width:18%">
                                            &nbsp;&nbsp;&nbsp; <span>排序</span>
                                        </div>
                                    </div>
                                    <div class="layui-form-item" style="width: 100%">
                                        <div class="layui-input-inline" style="width:18%">

                                            <select id="type" name="type" lay-filter="type" lay-verify="required">
                                                <option value="">作业类型</option>
                                                <option value='0'>搅拌桩</option>
                                            </select>
                                        </div>
                                        <div class="layui-input-inline" style="width: 18%">
                                            <input type="text" id="name" name="name" lay-verify="required"
                                                   lay-filter="name" autocomplete="off" placeholder="请输入名称"
                                                   class="layui-input">
                                        </div>
                                        <div class="layui-input-inline " style="width: 18%">
                                            <input type="text" id="logo" name="logo" lay-verify="required"
                                                   lay-filter="logo" autocomplete="off" placeholder="请输入英文字符"
                                                   class="layui-input">
                                        </div>
                                        <div class="layui-input-inline " style="width: 18%">
                                            <select id="warningRules" name="warningRules" lay-filter="warningRules">
                                                <option disabled selected style='display:none;'>请选择预警规则</option>
                                                <%--<option>搅拌桩</option>--%>
                                            </select>
                                        </div>
                                        <div class="layui-input-inline " style="width: 18%">
                                            <input type="text" id="sorting" name="sorting"
                                                   lay-filter="sorting" autocomplete="off"
                                                   class="layui-input">
                                        </div>
                                    </div>
                                    <div style="height: 70px">
                                        <b style="font-size: 17px; margin: 17px; float: left;">设计参数</b>
                                    </div>
                                    <div class="layui-form-item" style="background-color: #E6E6E6;height: 70px">
                                        <div class="layui-input-inline" style="margin: 17px;margin-right: 40px">

                                            <span id="sp1">
                                                <select id="parameterType" lay-filter="parameterType"
                                                        style="margin:-2px">
                                                     <option value="" disabled selected hidden>项目</option>
                                                </select>
                                            </span>
                                        </div>
                                        <div class="layui-input-inline" style="margin-top: 17px;">
                                            <input type="text" id="parameterVal" oninput="myFunction()"
                                                   lay-filter="parameterVal" autocomplete="off" placeholder="设计值"
                                                   class="layui-input">
                                        </div>
                                        <div class="layui-input-inline"
                                             style="width: 60px; margin-top:20px;margin-left:90px">
                                            <button class="layui-btn layui-btn-primary layui-btn-sm"
                                                    type="button" id="btn_add">
                                                添加
                                            </button>
                                        </div>
                                    </div>
                                    <div class="layui-form-item"
                                         style="height: 45%;overflow:auto;/*;border:1px solid*/ ">
                                        <table style="margin:10px 0px 0px 0px; " id="tb">

                                        </table>
                                    </div>
                                    <div class="layui-form-item">

                                        <div class="layui-input-inline"
                                             style="text-align:center;width: 70px;margin-left: 37%;">
                                            <div class="layui-btn layui-btn-radius layui-btn-normal" lay-submit=""
                                                 lay-filter="demo1" id="d1">
                                                添加
                                            </div>
                                        </div>
                                        <div class="layui-input-inline" style="text-align:center;width: 50px">
                                            <div class="layui-btn layui-btn-radius layui-btn-primary" type="button"
                                                 id="btn_off"
                                                 lay-filter="demo">取消
                                            </div>
                                        </div>
                                        <div class="layui-input-inline" style="width: 160px;margin-left: 20px">
                                            <security:authorize access="hasAnyRole('ROLE_SUPER_ADMIN,ROLE_ADMIN')">
                                                <select name="section" lay-verify="required" id="section">
                                                    <option value="">请选择配置的标段</option>
                                                </select>
                                            </security:authorize>
                                        </div>
                                        <%--<div class="row">
                                            <div class="col-xs-4" style="width: 150px;margin-left: 120px">
                                                &lt;%&ndash;<input type="text" class="form-control" placeholder=".col-xs-2">&ndash;%&gt;
                                                <security:authorize access="hasAnyRole('ROLE_SUPER_ADMIN,ROLE_ADMIN')">
                                                    <select class="form-control" id="section">
                                                        <option>请选择标段</option>
                                                    </select>
                                                </security:authorize>
                                            </div>
                                            <div class="col-xs-2">
                                                <button type="button" class="btn  btn-info">添加</button>
                                            </div>
                                            <div class="col-xs-2">
                                                <button type="button" class="btn btn-default ">取消</button>
                                            </div>
                                        </div>--%>
                                    </div>
                                    <%--      <div class="layui-form-item">
                                              <label class="layui-form-label">设备编号</label>
                                              <div class="layui-input-block">
                                                  <input type="text" id="devNum" name="devNum" lay-verify="required"
                                                         lay-filter="devNum" autocomplete="off" placeholder="请输入设备编号"
                                                         class="layui-input">
                                              </div>
                                          </div>
                                          <div class="layui-form-item">
                                              <label class="layui-form-label">机器编号</label>
                                              <div class="layui-input-block">
                                                  <input type="text" id="machineNum" name="machineNum" lay-verify="required"
                                                         lay-filter="machineNum" autocomplete="off" placeholder="请输入机器编号"
                                                         class="layui-input">
                                              </div>
                                          </div>


                                          <div class="layui-form-item">
                                              <label class="layui-form-label">所属项目</label>
                                              <div class="layui-input-block">
                                                  <select name="projectVal" id="projectVal" lay-filter="projectVal">
                                                      <option value="">请选择项目</option>
                                                  </select>
                                              </div>
                                          </div>
                                          <div class="layui-form-item">
                                              <label class="layui-form-label">所属标段</label>
                                              <div class="layui-input-block" id="sectionVal">
                                                  <select name="section_id" id="section_id" lay-filter="section_id">
                                                      <option value="">请选择标段</option>
                                                  </select>
                                              </div>
                                          </div>

                                          <div class="layui-form-item">
                                              <label class="layui-form-label">设备类型</label>
                                              <div class="layui-input-block">
                                                  <select name="state" id="devCode" lay-filter="devCode">
                                                      <option value="0">双头搅拌机</option>
                                                  </select>
                                              </div>
                                          </div>
                                          <div class="layui-form-item">
                                              <label class="layui-form-label">设备厂家</label>
                                              <div class="layui-input-block">
                                                  <input type="text" id="manufacturers" name="manufacturers" lay-verify="required"
                                                         lay-filter="manufacturers" autocomplete="off" placeholder="请输入设备厂家"
                                                         class="layui-input">
                                              </div>
                                          </div>
                                          <div class="layui-form-item">
                                              <label class="layui-form-label">排序ID</label>
                                              <div class="layui-input-block">
                                                  <input type="text" id="orderBy" name="orderBy" lay-verify="required"
                                                         autocomplete="off"
                                                         placeholder="请输入排序ID" class="layui-input">
                                              </div>
                                          </div>

                                          <div class="layui-form-item">
                                              <label class="layui-form-label">是否启用</label>
                                              <div class="layui-input-block">
                                                  <select name="state" id="state" lay-filter="state">
                                                      <option value="0">未激活</option>
                                                      <option value="1">已离线</option>
                                                      <option value="2">已离场</option>
                                                      <option value="3">运行中</option>
                                                      <option value="4">故障中</option>
                                                  </select>
                                              </div>
                                          </div>
                                          <div class="layui-form-item">
                                              <label class="layui-form-label">桩孔数量</label>
                                              <div class="layui-input-block">
                                                  <input type="text" id="devTotal" name="devTotal"
                                                         autocomplete="off" lay-verify="required"
                                                         class="layui-input">
                                              </div>
                                          </div>--%>

                                    <%--  <div class="layui-form-item">
                                        <div class="layui-input-block">
                                          <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
                                        </div>
                                      </div> --%>
                                </form>

                            </div>
                        </div>
                    </div>

                </div>
            </div>


            <script type="text/html" id="toolbarDemo">

                <%--<button class=" layui-icon-cols" lay-event="refresh">刷新</button>--%>
            </script>

            <script type="text/html" id="barDemo">
                <a class="layui-btn layui-btn-radius layui-btn-primary layui-btn-xs" lay-event="copy">复制</a>
                <a class="layui-btn layui-btn-radius layui-btn-primary layui-btn-xs" lay-event="edit">修改</a>
                <a class="layui-btn layui-btn-radius layui-btn-primary layui-btn-xs" lay-event="del">删除</a>
            </script>
            <script src="${pageContext.request.contextPath}/plugins/layui/layui.js" charset="utf-8"></script>
            <!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
        </section>
        <!-- 正文区域 /-->

    </div>
    <!-- @@close -->
    <!-- 内容区域 /-->


</div>


<script src="${pageContext.request.contextPath}/plugins/jQuery/jquery-2.2.3.min.js"></script>
<script src="${pageContext.request.contextPath}/plugins/jQueryUI/jquery-ui.min.js"></script>
<script>
    $.widget.bridge('uibutton', $.ui.button);
</script>
<script src="${pageContext.request.contextPath}/plugins/bootstrap/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/plugins/adminLTE/js/app.min.js"></script>
<script>
    //主体表格
    layui.use(['table', 'layer', 'form'], function () {
        var table = layui.table;
        var form = layui.form;
        var id = "${id}";
        table.render({
            elem: '#workSettingTable'
            , url: '/homeWorkSetting/findAll.do'
            , skin: "nob"
            , where: {userId: id}
            , method: 'post'
            , title: '设备列表'
            , cols: [[
                {type: 'checkbox', width: '5%', fixed: 'left'},
                {
                    field: 'name',
                    title: '名称',
                    width: '20%',
                    edit: 'text',
                    align: "center"
                }
                , {
                    field: 'logo',
                    title: '标识',
                    width: '20%',
                    edit: 'text',
                    align: "center"
                }
                , {
                    field: 'type',
                    title: '类型',
                    width: '20%',
                    edit: 'text',
                    align: "center",
                    templet: function (item) {
                        if (item.type == '0') {
                            return "搅拌桩";
                        }
                    }
                }
                , {
                    field: 'sorting', title: '排序', width: '15%', edit: 'text', align: "center"
                }
                , {title: '操作', toolbar: '#barDemo', width: '20%'}
            ]],
            done: function (res, curr, count) {
                $("table").css("width", "100%");
                //这里设置表格的宽度为100%
            }, page: true
            , id: 'testReload'
        });

        $('.demoTable .layui-btn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

        //重置
        $("#btn_off").click(function () {
            $("#book")[0].reset();
            $("#tb").find("tr").remove();
            $("#parameterVal").css({"border": "none"});
            $("#sp1").css({"border": "none"});
            $("#parameterType").html("<option value=''>项目</option>");
            form.render();
        })

        //作业参数下拉框联动
        form.on('select(type)', function (obj) {
            var parameterType = $("#parameterType");
            var html = "";
            $('#parameterVal').val("");
            $('#parameterVal').attr('placeholder', "设计值");
            if (obj.value === "0") {
                html += '<option value="">请选择</option>';
                html += '<option value="0">施工桩长</option>';
                html += '<option value="1">提升速度</option>';
                html += '<option value="2">下钻速度</option>';
                html += '<option value="3">平均灰量</option>';
                html += '<option value="4">最大斜度</option>';
                html += '<option value="5">初搅深度</option>';
                html += '<option value="6">复搅深度</option>';
                html += '<option value="7">空搅深度</option>';
                html += '<option value="8">水灰比</option>';
                parameterType.html(html);
                form.render('select');
            }
        });
        /*   form.on('select(parameterType)', function (obj) {
               parameterTypeVal = obj.elem[obj.elem.selectedIndex].text;


           })*/
        $("#btn_add").click(function () {
            var parameterVal = $("#parameterVal").val();
            var optionType = $("#parameterType option:selected").val();
            if (parameterVal && optionType) {
                var option = $("#parameterType option:selected").text();
                $("#tb").append('<tr><td class="mytd">' + option + '</td><td class="mytd">' + parameterVal + '</td><td class="mytd">' +
                    ' <a href="javascript:void(0);" onclick="editTd(this)">修改</a>\n' +
                    ' <a href="javascript:void(0);" onclick="delTr(this)">删除</a></td></tr>')
                $("#parameterType").find("option").first().attr("selected", true);
                $('#parameterVal').val("");
                $('#parameterVal').attr('placeholder', "设计值");
                form.render('select');
            }
            if (!optionType && parameterVal) {
                layer.msg('请选择参数类型', {shift: -1, icon: 5});
            }
            else if (!parameterVal && optionType) {
                $("#parameterVal").css({"border": "1px solid red"});
                layer.msg('请输入设计值', {shift: -1, icon: 5});
            } else if (!parameterVal && !optionType) {
                layer.msg('请选择参数类型', {shift: -1, icon: 5});
                $("#parameterType").parent().css({"border": "1px solid red", "position": "absolute"});
                $("#parameterVal").css({"border": "1px solid red"});
            }
        });

        /*   $("#parameterVal").focusout(function () {
               console.log($("#parameterVal").text())
               /!*if ($(this).text()){
                   $(this).css({"border": "none"});
               }*!/
                      // $(this).css({"border": "none"});
               // layer.msg($(this).val());
           });*/
        form.on('select(parameterType)', function (obj) {
            $("#sp1").css({"border": "none"});
        });
        /*    form.verify({
                type:function (value, item) {
                    console.log(value);
                }

            })*/

        form.on('submit(demo1)', function (data) {
            var pileNum = "";
            var speed = "";
            var drillingSpeed = "";
            var averageAsh = "";
            var largestSlope = "";
            var beginDepth = "";
            var mixingDepth = "";
            var emptyDepth = "";
            var waterCementRatio = "";
            $('#tb tr').each(function () {
                var firstTd = $(this).find("td:first").text()
                if (firstTd === "施工桩长") {
                    var secondTd = $(this).find("td:eq(1)").text();
                    pileNum = secondTd;
                } else if (firstTd === "提升速度") {
                    var secondTd = $(this).find("td:eq(1)").text();
                    speed = secondTd;
                } else if (firstTd === "下钻速度") {
                    var secondTd = $(this).find("td:eq(1)").text();
                    drillingSpeed = secondTd;
                } else if (firstTd === "平均灰量") {
                    var secondTd = $(this).find("td:eq(1)").text();
                    averageAsh = secondTd;
                } else if (firstTd === "最大斜度") {
                    var secondTd = $(this).find("td:eq(1)").text();
                    largestSlope = secondTd;
                } else if (firstTd === "初搅深度") {
                    var secondTd = $(this).find("td:eq(1)").text();
                    beginDepth = secondTd;
                } else if (firstTd === "复搅深度") {
                    var secondTd = $(this).find("td:eq(1)").text();
                    mixingDepth = secondTd;
                } else if (firstTd === "空搅深度") {
                    var secondTd = $(this).find("td:eq(1)").text();
                    emptyDepth = secondTd;
                } else if (firstTd === "水灰比") {
                    var secondTd = $(this).find("td:eq(1)").text();
                    waterCementRatio = secondTd;
                }
            });
            $("#parameterVal").css({"border": "none"});
            $("#sp1").css({"border": "none"});
            $.ajax({
                type: "post",
                url: "/homeWorkSetting/save.do",
                data: {
                    userId: id,
                    sectionId: $("#section").val(),
                    type: data.field.type,
                    name: data.field.name,
                    sorting: data.field.sorting,
                    logo: data.field.logo,
                    warningRules: data.field.warningRules,
                    pileNum: pileNum,
                    speed: speed,
                    drillingSpeed: drillingSpeed,
                    averageAsh: averageAsh,
                    largestSlope: largestSlope,
                    beginDepth: beginDepth,
                    mixingDepth: mixingDepth,
                    emptyDepth: emptyDepth,
                    waterCementRatio: waterCementRatio
                },
                success: function (data) {
                    if (data.result) {
                        // layer.msg(data.msg);
                        layer.msg(data.msg, {icon: 1});
                        $("#book")[0].reset();
                        $("#tb").find("tr").remove();
                        $("#parameterVal").css({"border": "none"});
                        $("#sp1").css({"border": "none"});
                        $("#parameterType").html("<option value=''>项目</option>");
                        form.render();
                    } else {
                        layer.msg('添加失败', {icon: 2});
                    }
                    table.reload('testReload', {//重载表格
                        page: {
                            curr: 1,
                            where: {
                                userId: id
                            }
                        }
                    })
                }
            })
            return false;
        })


        //监听行工具事件
        table.on('tool(workSettingTable)', function (obj) {
            if (obj.event === 'copy') {
                console.log(obj.data);
                $("#b1").text("添加作业配置")
                $("#d1").text("添加")
                $("#type").val(obj.data.type);
                $("#name").val(obj.data.name);
                $("#logo").val(obj.data.logo);
                $("#warningRules").val(obj.data.warningRules);
                $("#sorting").val(obj.data.sorting);
                $("#section").val(obj.data.sectionId);
                if (obj.data.type === "0") {
                    var option = "";
                    option += '<option value="">请选择</option>';
                    option += '<option value="0">施工桩长</option>';
                    option += '<option value="1">提升速度</option>';
                    option += '<option value="2">下钻速度</option>';
                    option += '<option value="3">平均灰量</option>';
                    option += '<option value="4">最大斜度</option>';
                    option += '<option value="5">初搅深度</option>';
                    option += '<option value="6">复搅深度</option>';
                    option += '<option value="7">空搅深度</option>';
                    option += '<option value="8">水灰比</option>';
                    $("#parameterType").html(option);
                }
                var html = "";
                if (obj.data.pileNum) {
                    html += '<tr><td class="mytd">施工桩长</td><td class="mytd">' + obj.data.pileNum + '</td><td class="mytd">' +
                        ' <a href="javascript:void(0);" onclick="editTd(this)">修改</a>\n' +
                        ' <a href="javascript:void(0);" onclick="delTr(this)">删除</a></td></tr>';
                }
                if (obj.data.speed) {
                    html += '<tr><td class="mytd">提升速度</td><td class="mytd">' + obj.data.speed + '</td><td class="mytd">' +
                        ' <a href="javascript:void(0);" onclick="editTd(this)">修改</a>\n' +
                        ' <a href="javascript:void(0);" onclick="delTr(this)">删除</a></td></tr>';
                }
                if (obj.data.drillingSpeed) {
                    html += '<tr><td class="mytd">下钻速度</td><td class="mytd">' + obj.data.drillingSpeed + '</td><td class="mytd">' +
                        ' <a href="javascript:void(0);" onclick="editTd(this)">修改</a>\n' +
                        ' <a href="javascript:void(0);" onclick="delTr(this)">删除</a></td></tr>';
                }
                if (obj.data.averageAsh) {
                    html += '<tr><td class="mytd">平均灰量</td><td class="mytd">' + obj.data.averageAsh + '</td><td class="mytd">' +
                        ' <a href="javascript:void(0);" onclick="editTd(this)">修改</a>\n' +
                        ' <a href="javascript:void(0);" onclick="delTr(this)">删除</a></td></tr>';
                }
                if (obj.data.largestSlope) {
                    html += '<tr><td class="mytd">最大斜度</td><td class="mytd">' + obj.data.largestSlope + '</td><td class="mytd">' +
                        ' <a href="javascript:void(0);" onclick="editTd(this)">修改</a>\n' +
                        ' <a href="javascript:void(0);" onclick="delTr(this)">删除</a></td></tr>';
                }
                if (obj.data.beginDepth) {
                    html += '<tr><td class="mytd">初搅深度</td><td class="mytd">' + obj.data.beginDepth + '</td><td class="mytd">' +
                        ' <a href="javascript:void(0);" onclick="editTd(this)">修改</a>\n' +
                        ' <a href="javascript:void(0);" onclick="delTr(this)">删除</a></td></tr>';
                }
                if (obj.data.mixingDepth) {
                    html += '<tr><td class="mytd">复搅深度</td><td class="mytd">' + obj.data.mixingDepth + '</td><td class="mytd">' +
                        ' <a href="javascript:void(0);" onclick="editTd(this)">修改</a>\n' +
                        ' <a href="javascript:void(0);" onclick="delTr(this)">删除</a></td></tr>';
                }
                if (obj.data.emptyDepth) {
                    html += '<tr><td class="mytd">空搅深度</td><td class="mytd">' + obj.data.emptyDepth + '</td><td class="mytd">' +
                        ' <a href="javascript:void(0);" onclick="editTd(this)">修改</a>\n' +
                        ' <a href="javascript:void(0);" onclick="delTr(this)">删除</a></td></tr>';
                }
                if (obj.data.waterCementRatio) {
                    html += '<tr><td class="mytd">水灰比</td><td class="mytd">' + obj.data.waterCementRatio + '</td><td class="mytd">' +
                        ' <a href="javascript:void(0);" onclick="editTd(this)">修改</a>\n' +
                        ' <a href="javascript:void(0);" onclick="delTr(this)">删除</a></td></tr>';
                }
                $("#tb").html(html);
                form.render('select');
            } else if (obj.event === 'edit') {
                console.log(obj.data);
                $("#b1").text("修改作业配置")
                $("#d1").text("修改")
                $("#type").val(obj.data.type);
                $("#name").val(obj.data.name);
                $("#logo").val(obj.data.logo);
                $("#warningRules").val(obj.data.warningRules);
                $("#sorting").val(obj.data.sorting);
                $("#section").val(obj.data.sectionId);
                if (obj.data.type === "0") {
                    var option = "";
                    option += '<option value="">请选择</option>';
                    option += '<option value="0">施工桩长</option>';
                    option += '<option value="1">提升速度</option>';
                    option += '<option value="2">下钻速度</option>';
                    option += '<option value="3">平均灰量</option>';
                    option += '<option value="4">最大斜度</option>';
                    option += '<option value="5">初搅深度</option>';
                    option += '<option value="6">复搅深度</option>';
                    option += '<option value="7">空搅深度</option>';
                    option += '<option value="8">水灰比</option>';
                    $("#parameterType").html(option);
                }
                var html = "";
                if (obj.data.pileNum) {
                    html += '<tr><td class="mytd">施工桩长</td><td class="mytd">' + obj.data.pileNum + '</td><td class="mytd">' +
                        ' <a href="javascript:void(0);" onclick="editTd(this)">修改</a>\n' +
                        ' <a href="javascript:void(0);" onclick="delTr(this)">删除</a></td></tr>';
                }
                if (obj.data.speed) {
                    html += '<tr><td class="mytd">提升速度</td><td class="mytd">' + obj.data.speed + '</td><td class="mytd">' +
                        ' <a href="javascript:void(0);" onclick="editTd(this)">修改</a>\n' +
                        ' <a href="javascript:void(0);" onclick="delTr(this)">删除</a></td></tr>';
                }
                if (obj.data.drillingSpeed) {
                    html += '<tr><td class="mytd">下钻速度</td><td class="mytd">' + obj.data.drillingSpeed + '</td><td class="mytd">' +
                        ' <a href="javascript:void(0);" onclick="editTd(this)">修改</a>\n' +
                        ' <a href="javascript:void(0);" onclick="delTr(this)">删除</a></td></tr>';
                }
                if (obj.data.averageAsh) {
                    html += '<tr><td class="mytd">平均灰量</td><td class="mytd">' + obj.data.averageAsh + '</td><td class="mytd">' +
                        ' <a href="javascript:void(0);" onclick="editTd(this)">修改</a>\n' +
                        ' <a href="javascript:void(0);" onclick="delTr(this)">删除</a></td></tr>';
                }
                if (obj.data.largestSlope) {
                    html += '<tr><td class="mytd">最大斜度</td><td class="mytd">' + obj.data.largestSlope + '</td><td class="mytd">' +
                        ' <a href="javascript:void(0);" onclick="editTd(this)">修改</a>\n' +
                        ' <a href="javascript:void(0);" onclick="delTr(this)">删除</a></td></tr>';
                }
                if (obj.data.beginDepth) {
                    html += '<tr><td class="mytd">初搅深度</td><td class="mytd">' + obj.data.beginDepth + '</td><td class="mytd">' +
                        ' <a href="javascript:void(0);" onclick="editTd(this)">修改</a>\n' +
                        ' <a href="javascript:void(0);" onclick="delTr(this)">删除</a></td></tr>';
                }
                if (obj.data.mixingDepth) {
                    html += '<tr><td class="mytd">复搅深度</td><td class="mytd">' + obj.data.mixingDepth + '</td><td class="mytd">' +
                        ' <a href="javascript:void(0);" onclick="editTd(this)">修改</a>\n' +
                        ' <a href="javascript:void(0);" onclick="delTr(this)">删除</a></td></tr>';
                }
                if (obj.data.emptyDepth) {
                    html += '<tr><td class="mytd">空搅深度</td><td class="mytd">' + obj.data.emptyDepth + '</td><td class="mytd">' +
                        ' <a href="javascript:void(0);" onclick="editTd(this)">修改</a>\n' +
                        ' <a href="javascript:void(0);" onclick="delTr(this)">删除</a></td></tr>';
                }
                if (obj.data.waterCementRatio) {
                    html += '<tr><td class="mytd">水灰比</td><td class="mytd">' + obj.data.waterCementRatio + '</td><td class="mytd">' +
                        ' <a href="javascript:void(0);" onclick="editTd(this)">修改</a>\n' +
                        ' <a href="javascript:void(0);" onclick="delTr(this)">删除</a></td></tr>';
                }
                $("#tb").html(html);
                form.render('select');
            } else if (obj.event === 'del') {
                layer.confirm('此操作将永久删除该配置(配置名:'+obj.data.name+'), 是否继续?' ,{icon: 2, title:'提示'}, function (index) {
                    $.ajax({
                        type: "post",
                        url: "/homeWorkSetting/delete.do",
                        data: {
                            id: obj.data.id
                        },
                        success: function (Data) {
                            if (Data.result) {
                                layer.msg("删除成功");
                                obj.del();//删除当前行
                                layer.close(index);//关闭弹出层
                            } else {
                                layer.msg("删除失败");
                                layer.close(index);//关闭弹出层
                            }
                        }, error: function () {
                            layer.msg("删除失败");
                            layer.close(index);//关闭弹出层
                        }
                    })
                });
            }
        });
    });


    /*    $(document).ready(function () {
            // 选择框
            $(".select2").select2();

            // WYSIHTML5编辑器
            $(".textarea").wysihtml5({
                locale: 'zh-CN'
            });
        });*/
    //设置设计值输入框输入事件
    function myFunction() {
        $("#parameterVal").css({"border": "none"});
    }

    //删除一行
    function delTr(obj) {
        $(obj).parent().parent().remove();
    }

    //修改一行
    function editTd(obj) {
        $(obj).html("确定");
        $(obj).css("color", "#58FA82");
        $(obj).removeAttr("onclick");
        $(obj).attr("onclick", "confirm(this);");
        var val = $(obj).parent().parent().children("td").eq(1).html();
        var td = $(obj).parent().parent().children("td").eq(1);
        td.html('<input type="text" style="width: 60px" value="' + val + '"></input>')
    }

    //确定修改的数据
    function confirm(obj) {
        // alert(obj)
        $(obj).html("修改");
        $(obj).css("color", "black");
        $(obj).removeAttr("onclick");
        $(obj).attr("onclick", "editTd(this);");
        var val = $(obj).parent().parent().children("td").eq(1).children().val();
        var td = $(obj).parent().parent().children("td").eq(1);
        td.html(val);
    }

    /*获取标段信息*/
    $(function () {
        var id = "${id}";
        $.ajax({
            type: "get",
            url: "/section/sectionGroupNameByUserId.do",
            data: {
                userId: id
            },
            success: function (Data) {
                var section = $("#section");
                var html = "";
                for (var i = 0; i < Data.length; i++) {
                    html += '<option value="' + Data[i].id + '">' + Data[i].sectionName + '</option>';
                }
                section.append(html);
                // form.render('select');
            }
        });
    })

    // 设置激活菜单
    /*    function setSidebarActive(tagUri) {
            var liObj = $("#" + tagUri);
            if (liObj.length > 0) {
                liObj.parent().parent().addClass("active");
                liObj.addClass("active");
            }
        }*/

    /*  layui.use('form', function () {
          var form = layui.form;
          //获取项目列表
          $.ajax({
              type: "get",
              url: "/project/projectGroupName.do",
              success: function (Data) {
                  // console.log(Data)
                  var project = $("#projectId");
                  var projectVal = $("#projectVal");
                  var html = "";
                  for (var i = 0; i < Data.length; i++) {
                      html += '<option value="' + Data[i].id + '">' + Data[i].projectName + '</option>';
                  }
                  project.append(html);
                  projectVal.append(html);
                  form.render('select');
              }
          });
          //获取标段列表
          $.ajax({
              type: "get",
              url: "/section/sectionGroupName.do",
              success: function (Data) {
                  // console.log(Data)
                  var section = $("#sectionId");
                  var sectionVal = $("#section_id");

                  var html = "";

                  for (var i = 0; i < Data.length; i++) {
                      html += '<option value="' + Data[i].id + '">' + Data[i].sectionName + '</option>';
                  }
                  section.append(html);
                  sectionVal.append(html);
                  form.render('select');
              }
          });

      })*/


    /* $(document).ready(function () {

         // 激活导航位置
         setSidebarActive("admin-datalist");

         // 列表按钮
         $("#dataList td input[type='checkbox']").iCheck({
             checkboxClass: 'icheckbox_square-blue',
             increaseArea: '20%'
         });
         // 全选操作
         $("#selall").click(function () {
             var clicks = $(this).is(':checked');
             if (!clicks) {
                 $("#dataList td input[type='checkbox']").iCheck("uncheck");
             } else {
                 $("#dataList td input[type='checkbox']").iCheck("check");
             }
             $(this).data("clicks", !clicks);
         });

     });*/
    /*    $('.navbar-static-top').on('bsTransitionEnd', function () {
            _this.fix();
            _this.fixSidebar();
        });*/
</script>
</body>

</html>
